<?php
/**
 * Created by PhpStorm.
 * User: mr.lee
 * Date: 2018/8/24
 * Time: 下午4:08
 */

namespace app\common\controller;


use think\Config;
use think\Controller;

class ActionLogs extends Controller
{
    public function writelog($obj,$model,$action,$other,$data){

        $cfg =Config::get('actionlog');
        $dir_path=$cfg.DS.$obj.DS.$model.DS.$action.DS;
        if(!is_dir($dir_path)){
            mkdir($dir_path,0777,true);
        }
        $filename=$dir_path.date('Y-m-d').".log";
        file_put_contents($filename,'['.date('Y-m-d H:i:s').']'.$other.json_encode($data, JSON_UNESCAPED_UNICODE) . PHP_EOL, FILE_APPEND);
        return $filename;
    }
}